How to install APC (PHP Cache)
What is APC?
APC is a free, open, and robust framework for caching and optimizing PHP intermediate code.
Install instructions
- Login to the server as root
- Download APC
- Extract and move into the directory
- Locate where php is
- Create configuration files
- Compile APC
- Install APC into php.ini
- Restart Apache
wget http://pecl.php.net/get/APC-3.0.14.tgz
gzip -d APC-3.0.14.tgz
tar -xf APC-3.0.14.tar
cd APC-3.0.14
which php
This should return something like: /usr/local/bin/php
We have to remember the location of php
phpize
./configure –enable-apc –enable-apc-mmap –with-apxs –with-php-config=/usr/local/bin/php-config
make
make install
The “make install” commnand will return the location of the apc.so extention please note the location. You will need this later.
You will have to first locate php using the locate command
locate php
This will usualy return /usr/local/Zend/etc/php.ini on a server that has Zend optimizer installed.
Now we will edit php.ini and add the APC extension.
pico /usr/local/Zend/etc/php.ini
Scroll down to the buttom and add the fallowing before the lines about the zend optimizer (They start with [Zend])
extension=”/apc_location/apc.so”
If you done everything it’s time to restart Apache
service httpd restart
Hope this helps !
If you enjoyed this post, make sure you subscribe to my RSS feed!
- September 7th


(2 votes, average: 4.50 out of 5)










For others who found this as easy to use as I did, a couple of notes.
If your running suPHP like I am, then leave out –with-apxs.
Also, don’t try to copy and paste this on the terminal line. Each one of the above dashes is actually two dashes – - together. It just doesn’t copy/paste well
Thanks for the informative article!
Hi Eric
You say to leave out -with-apxs when running suphp
I did that, but found that APC isn’t caching very many files, infact, only 16 on my entire web server
If I switch the php handler to DSO, or FCGI however, that figure rises quite dramatically
Have you managed to get apc working properly with suphp? If so, could you post how you did it?
I am curious how much something like this would improve a custom built site rather than wordpress or drupal. Should I see a noticeable improvement for just about anything?
I have heard optimization scripts such as this can crash apache so I want to make sure it is worth the risk…
A couple other things left out in this tutorial:
In php.ini you should have this:
In the ‘Paths and Directories’ section of your php.ini you’ll see this:
; Directory in which the loadable extensions (modules) reside.
extension_dir = “/usr/local/lib/php/extensions/no-debug-non-zts-20060613″
extension = “apc.so”
And the most important part that isnt mentioned above:
Just below:
; Maximum allowed size for uploaded files.
upload_max_filesize = ??m
Add this:
apc.rfc1867 = On
Now it will work.
Just to let you know that step #7 should read “locate php.ini” and not “locate php” …
Step 6: compile apc, its says it can configure only one host and one targe at a time, i have two domains pointing to two diff folders in root, how does it work?
thanks
I tried moving APC folder to one of my domain and redo the steps but it says same; can configure one host and one target at a time. any suggestion?
when i try to run the 6 step it gaves me an error
-bash: cd: /configure: No such file or directory
do you know how to fix it please
Is it necessary to upgrade to php5 for apc installation? I have installed the apc.
when i give php -m i can’t see apc module. but i have enabled apc in php.ini